package com.example.exintent2;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {
	EditText ed1,ed2;
	Button but1;
	TextView txt1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ed1=(EditText) findViewById(R.id.ed1);
        ed2=(EditText) findViewById(R.id.ed2);
        txt1=(TextView) findViewById(R.id.txt1);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
    public void send_son(View v) {
    	int aa = Integer.parseInt(ed1.getText().toString());
		int b= Integer.parseInt(ed2.getText().toString());
		Intent m = new Intent(MainActivity.this,Activity_con.class);
		m.putExtra("num1", aa);
		m.putExtra("num2", b);
		startActivityForResult(m, 111);
		
	}
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    	// TODO Auto-generated method stub
    	super.onActivityResult(requestCode, resultCode, data);
    	if(requestCode==111){
    	switch (resultCode) {
		case 112:
			int mon = data.getIntExtra("con", 0);
    		String lido = data.getStringExtra("lydo");
    		txt1.setText(""+mon);
    		Toast.makeText(this, lido, Toast.LENGTH_LONG).show();
			break;

		default:
			break;
		}
    	
    	}
    }
}
